//
//  CYFinanceDetailViewModel.m
//  cyjf
//
//  Created by tauCross on 2017/5/7.
//  Copyright © 2017年 Auto Financing. All rights reserved.
//

#import "CYFinanceDetailViewModel.h"



@implementation CYFinanceDetailViewModel

+ (instancetype)modelWithAPIModel:(CYDataAPIFinanceModel *)apiModel
{
    CYFinanceDetailViewModel *model = [super modelWithAPIModel:apiModel];
    model.total = [NSString stringWithFormat:@"%@元", [SAFE_NUMBER(apiModel.amount).amountString componentsSeparatedByString:@"."].firstObject];
    model.start = [NSString stringWithFormat:@"%@元", [SAFE_NUMBER(apiModel.moneyMin).amountString componentsSeparatedByString:@"."].firstObject];
    model.memberCount = [NSString stringWithFormat:@"%li人", SAFE_NUMBER(apiModel.investTimes).longValue];
    model.balance = [NSString stringWithFormat:@"%@元", [SAFE_NUMBER(apiModel.able).amountString componentsSeparatedByString:@"."].firstObject];
    NSDate *dueDate = [NSDate dateWithTimeIntervalSince1970:SAFE_NUMBER(apiModel.endTime).doubleValue / 1000.0];
    model.dueDate = [dueDate cy_stringWithFormat:@"yyyy-MM-dd"];
    model.due = [NSString stringWithFormat:@"%li天", (SAFE_NUMBER(apiModel.duration).longValue)];
    model.limit = ([apiModel.moneyMax isKindOfClass:[NSNumber class]] && apiModel.moneyMax.integerValue > 0) ? [NSString stringWithFormat:@"%@元", [apiModel.moneyMax.amountString componentsSeparatedByString:@"."].firstObject] : @"不限额";
    return model;
}

@end
